package com.wechat.enums;

import com.swak.utils.StringUtils;
import com.wechat.Cons;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum ContactType {

	/**
	 * 个人
	 */
	User((byte) 1),

	/**
	 * 助手
	 */
	Assistant((byte) 2),

	/**
	 * 群聊
	 */
	Chat_Room((byte) 9);

	public final byte type;

	/**
	 * 通过聊天人判断类型
	 * 
	 * @param talker
	 * @return
	 */
	public static ContactType of(String talker) {
		if (StringUtils.endsWith(talker, Cons.ID_ChatRoom)) {
			return ContactType.Chat_Room;
		} else if (StringUtils.endsWith(talker, Cons.ID_Robot)) {
			return ContactType.Assistant;
		}
		return ContactType.User;
	}
}
